﻿<%--
   Copyright 2012 University of Southampton

   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.
--%>

<%@ Assembly Name="$SharePoint.Project.AssemblyFullName$" %>
<%@ Import Namespace="Microsoft.SharePoint.ApplicationPages" %>
<%@ Register Tagprefix="SharePoint" Namespace="Microsoft.SharePoint.WebControls" Assembly="Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Register Tagprefix="Utilities" Namespace="Microsoft.SharePoint.Utilities" Assembly="Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Register Tagprefix="asp" Namespace="System.Web.UI" Assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" %>
<%@ Import Namespace="Microsoft.SharePoint" %>
<%@ Assembly Name="Microsoft.Web.CommandUI, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="ParameterGraphXY.aspx.cs" Inherits="uk.ac.soton.ses.layouts.ParameterGraphXY" %>

<%@ Register Assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
    Namespace="System.Web.UI.WebControls" TagPrefix="asp" %>

<%@ Register TagPrefix="hdc" Namespace="uk.ac.soton.ses.WebControls" Assembly="HDCWebControls, Version=1.0.0.0, Culture=neutral, PublicKeyToken=be2a37f6f7c4bcce" %>
<%@ Register TagPrefix="hdc" TagName="ExperimentMultipleSelection" Src="/_ControlTemplates/uk.ac.soton.ses/HDCUserControls/ExperimentMultipleSelection.ascx" %>
<%@ Register TagPrefix="hdc" TagName="ExperimentQuickSearch" Src="/_ControlTemplates/uk.ac.soton.ses/HDCUserControls/ExperimentQuickSearch.ascx" %>

<html>

<head runat="server">
<title>Parameter Graph X Y</title>
<style type="text/css">
    
    /*#ReportTable{font-family:Sans-Serif;font-size:10pt;}*/
    body {font-family:Sans-Serif;font-size:10pt;}
    #ReportTable td,#ReportTable th {padding:0px 10px 0px 10px;text-align:left;}
    #ReportTable th {font-weight:bold;}
    #ReportTable td { border: 1px solid grey;}

    @media screen
    {
        body {font-size:8pt;}
        .ReportDiv {float:left;}
        #ReportConfigurationDiv {width:400px;}
        #ReportOutputDiv {width:700px;}

        #DatasetSelectionDiv{background-color:#bbddff;}
        #ParameterSelectionDiv{background-color:#aaddaa;}
        table.FieldSelection {font-size:8pt;}
        #ReportTableDiv {height:460px;overflow:auto;}

        .OptionLabel{float:left;width:12em;clear:left;}
        .OptionBox{float:left;width:3em;}
        .OptionDiv{background-color:#aaffaa;}
        .InfoDiv{background-color:#dddddd;}
        .ExcludedItems{color:Red;}
        
        .SelectionDiv {overflow:auto;font-family:Helvetica, Arial, sans-serif;font-size:7pt;}
        .SelectionDiv input {font-family:inherit;font-size:inherit;}
        .ParameterSeriesOneColumnCell{float:left;width:45px;}
        .ParameterSeriesTwoColumnCell{float:left;width:90px;word-wrap:break-word;}
        .ParameterSeriesThreeColumnCell{float:left;width:135px;word-wrap:break-word;}
        .ParameterSeriesFourColumnCell{float:left;width:180px;word-wrap:break-word;}
        .ParameterSeriesFiveColumnCell{float:left;width:225px;word-wrap:break-word;}
        .ParameterSeriesSixColumnCell{float:left;width:270px;word-wrap:break-word;}
        .ParameterSeriesTextBox{width:42px;}
        
        .ui-autocomplete {max-height: 100px; overflow: auto;}
        .ui-menu-item {font-family:Helvetica, Arial, sans-serif;font-size:8pt;}
    }
    
    @media print
    {
        .NonPrintDiv{display:none;}
        #ReportTable{font-family:Serif}
    }
</style>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js" type="text/javascript"></script>
<script src="//ajax.googleapis.com/ajax/libs/jqueryui/1.8.24/jquery-ui.min.js" type="text/javascript"></script>
<script src="/_layouts/HDC/Scripts/HighCharts-3.0.10/js/highcharts.js" type="text/javascript"></script>
<link rel="Stylesheet" href="//code.jquery.com/ui/1.8.24/themes/base/jquery-ui.css" type="text/css" />
</head>

<body>
<form ID="form" runat="server">
    <div id="ReportConfigurationDiv" class="ReportDiv NonPrintDiv">

        <%--Dataset selection--%>
        <hdc:ExperimentMultipleSelection ID="ctl_ExperimentMultipleSelection" runat="server"/>

        <%--Parameter selection--%>
        <div id="ParameterSelectionDiv">
            <div style="height:35px">
                <div style="float:left;clear:left">
                    <b>Parameter selection:</b>
                    <asp:LinkButton ID="btn_Refresh" runat="server" Text="Refresh" OnClick="btn_Refresh_Click" CssClass="ActionLink" />
                </div>
                <div class="SelectionDiv" style="float:left;clear:left">
                    <div class="ParameterSeriesOneColumnCell"><b>X Series</b></div>
                    <div class="ParameterSeriesOneColumnCell"><b>Y Series</b></div>
                    <div class="ParameterSeriesFiveColumnCell"><b>Parameter</b></div>
                    <div class="ParameterSeriesOneColumnCell"><b>Find all</b></div>
                </div>
            </div>
            <div class="SelectionDiv" style="height:185px">
                <asp:ListView ID="ListView_GlobalParameters" runat="server" DataKeyNames="DataItemName,SelectionKey">
                    <LayoutTemplate>
                        <div style="float:left;clear:left"><b>Cross-dataset parameters</b></div>
                        <div runat="server">
                            <div runat="server" id="itemPlaceholder"></div>
                        </div>
                    </LayoutTemplate>
                    <ItemTemplate>
                        <div runat="server" style="float:left;clear:left">
                            <div runat="server" class="ParameterSeriesOneColumnCell"><asp:TextBox ID="txt_XGlobalParam" runat="server"  text='<%# Eval("XSeries") %>' CssClass="ParameterSeriesTextBox" OnTextChanged="txt_GlobalParam_TextChanged" /></div>
                            <div runat="server" class="ParameterSeriesOneColumnCell"><asp:TextBox ID="txt_YGlobalParam" runat="server"  text='<%# Eval("YSeries") %>' CssClass="ParameterSeriesTextBox" OnTextChanged="txt_GlobalParam_TextChanged" /></div>
                            <div runat="server" class="ParameterSeriesFiveColumnCell"><asp:TextBox ID="txt_GlobalParamName" runat="server" text='<%# Eval("DataItemName") %>' CssClass="ParameterSeriesTextBox" OnTextChanged="txt_GlobalParam_TextChanged" /></div>
                        </div>
                    </ItemTemplate>
                </asp:ListView>
                <asp:ListView ID="ListView_Parameters" runat="server" DataKeyNames="ExperimentID,ParentParameterID,DataItemName,ParameterIDPath">
                    <LayoutTemplate>
                        <div style="float:left;clear:left"><b>Specific parameters</b></div>
                        <div runat="server">
                            <div runat="server" id="itemPlaceholder"></div>
                        </div>
                    </LayoutTemplate>
                    <ItemTemplate>
                            <div runat="server" style="float:left;clear:left">
                                <div runat="server" class="ParameterSeriesOneColumnCell"><asp:TextBox ID="txt_XParam" runat="server" text='<%# Eval("XSeries") %>' CssClass="ParameterSeriesTextBox" OnTextChanged="txt_Param_TextChanged" /></div>
                                <div runat="server" class="ParameterSeriesOneColumnCell"><asp:TextBox ID="txt_YParam" runat="server" text='<%# Eval("YSeries") %>' CssClass="ParameterSeriesTextBox" OnTextChanged="txt_Param_TextChanged" /></div>
                                <div runat="server" class="ParameterSeriesFiveColumnCell"><asp:Label ID="lbl_ParameterName" runat="server" text='<%# Eval("ParameterNamePath") %>' /></div>
                                <div runat="server" class="ParameterSeriesOneColumnCell">&#91;&nbsp;<asp:LinkButton id="btn_MakeXParameterGlobal" runat="server" Text="X" OnClick="MakeParameterGlobal" />&nbsp;&#124;&nbsp;<asp:LinkButton id="btn_MakeYParameterGlobal" runat="server" Text="Y" OnClick="MakeParameterGlobal" />&nbsp;&#93;</div>
                            </div>
                    </ItemTemplate>
                </asp:ListView>
            </div>
        </div>

        <%--Info--%>
        <div>
            <p>If the number of parameters found for X and Y do not match, or there are multiple parameters with no Position defined, we will only select parameters by their Position field, matching the X parameter with the immediately following Y parameter and ignoring parameters if there are multiple matches. This could mean that if there are four X values and three Y values, the last X parameter might be matched to the first Y parameter. <b>This may not be what you expect.</b></p>
            <p>If the number of parameters found for X and Y do match, we will sort them by Position and select them alternately, so the first X parameter will be matched with the first Y parameter.</p>
            <p><span style="color:red">These approaches produce wildly different results, so please ensure your X and Y parameters are correct.</span> The safest approach is to ensure there are equal number of X and Y values matching the parameter name you select, and they are in a sensible order using the Position field.</p>
        </div>
    </div>
    <div id="ReportOutputDiv" class="ReportDiv">
        <div id="ReportTableDiv">
            <div id="graphcontainer"></div>
            <asp:PlaceHolder ID="PlaceHolder_Messages" runat="server" />
        </div>
        <asp:Panel id="ReportButtons" class="NonPrintDiv" runat="server" style="float:left;width:100%">
            <div style="float:left;width:100%">
                <b>Graph configuration</b>
                <ul class="hdctoolbullets">
                    <li class="hdctool"><asp:Label ID="Label1" runat="server" AssociatedControlID="txt_XAxisTitle" Text="X Title:" /><asp:TextBox ID="txt_XAxisTitle" runat="server" OnTextChanged="txt_ChartInfoChanged"/></li>
                    <li class="hdctool"><asp:Label ID="Label2" runat="server" AssociatedControlID="txt_YAxisTitle" Text="Y Title:"/><asp:TextBox ID="txt_YAxisTitle" runat="server" OnTextChanged="txt_ChartInfoChanged" /></li>
                    <li class="hdctool"><asp:Label ID="Label3" runat="server" AssociatedControlID="txt_ChartTitle" Text="Chart Title:"/><asp:TextBox ID="txt_ChartTitle" runat="server" OnTextChanged="txt_ChartInfoChanged" />
                    <asp:LinkButton ID="LinkButton1" runat="server" Text="Refresh" CssClass="ActionLink" /></li>
                </ul>
            </div>
            <div style="float:left">
                <b>Report tools</b>
                <%--Report save buttons go here--%>
                <ul class="hdctoolbullets">
                    <li class="hdctool"><hdc:ExperimentQuickSearch ID="ctl_SaveReportExperimentQuickSearch" runat="server" SearchLabelText="Save report to experiment (enter ID or search):" OKButtonText="Save"/>
                    <asp:PlaceHolder ID="PlaceHolder_SaveReportToExperimentMessages" runat="server" /></li>
                </ul>
            </div>
            <div style="float:right">
                <%--Graph configuration buttons go here--%>
            </div>
        </asp:Panel>
    </div>
</form>
</body>

</html>